package com.bugman.managed;

import com.bugman.entity.Role;
import com.bugman.entity.User;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.model.SelectItem;

/**
 *
 * @author ediczech
 */
public class PromoteUserBean extends BaseBean {

    private List<User> developers = new ArrayList<User>();
    private List<String> developerNames = new ArrayList<String>();
    private List<SelectItem> users = new ArrayList<SelectItem>();

    @PostConstruct
    public void init() {
        // create List of selectItems
        for (User user : userService.getUsers(Role.USER)) {
            users.add(new SelectItem(user.getId().toString(), user.getNick()));
        }
    }

    public String promote() {
        //developers = userService.getUsers(developerNames);
        userService.setDevelopers(developers);
        return "success";
    }
}
